<template>
    <div class="daily-of">
        <tittle-one>
            <div style="display: flex;justify-content: space-between; align-content: center">
                <div style="font-size: 1.5rem; line-height: 40px">每日素材</div>
                <div>
                    <el-button @click="typeClk('cb')" :type="urlType('cb')">拆包网</el-button>
                    <el-button @click="typeClk('mhy')" :type="urlType('mhy')">米游社</el-button>
                </div>
            </div>
        </tittle-one>
        <div class="week-tab">
            <el-button @click="week=1" :type="btnType(1)">周一/周四</el-button>
            <el-button @click="week=2" :type="btnType(2)">周二/周五</el-button>
            <el-button @click="week=3" :type="btnType(3)">周三/周六</el-button>
            <el-button @click="week=0" :type="btnType(0)">周日(全部)</el-button>
        </div>
        <div class="daily-main">
            <daily :role="role" :weapon="weapon" :week="week" />
        </div>
    </div>
</template>

<script>
  import js from '@/data/js'
  import wq from '@/data/wq'
  import TittleOne from '../temp/TittleOne.vue'
  import Daily from  '../temp/Daily.vue'
  import { getWeek, dateFormat } from '@/util/daelTime'
  import * as com from '@/data/com'
  import { goto } from '../../util/request'


  export default {
    name: "DailyOf",
    components: {
      TittleOne,
      Daily
    },
    data() {
      return {
        act: 'mhy',
        week: 1,
        role: [],
        weapon: []
      }
    },
    methods: {
      btnType(index) {
        return this.week===index?'success':'primary'
      },
      urlType(type) {
        return this.act===type?'success':'primary'
      },
      typeClk(type) {
        this.act = type
        this.$router.push({path: '/my/index', query: {type : type, time: new Date().valueOf().toString()}})
        window.location.reload()
      },
      init() {
        this.role = js
        this.weapon = wq
        const tstr = this.$route.query.type
        if(!tstr) {
          this.$router.push({path: '/my/index', query: {type : 'mhy', time: new Date().valueOf().toString()}})
        }
        if(tstr && com[tstr]) {
          this.act = tstr
        }
        const t = getWeek(new Date())
        this.week = t > 3 ? t - 3 : t
        console.log('+++++星期+++++', this.week ? this.week : 7);
      }
    },
    created() {
      this.init()
    }
  }
</script>

<style lang="less" scoped>
    .daily-of {
        .week-tab {
            width: 100%;
            display: flex;
            justify-content: center;
            .el-button {
                margin: 0 2px;
                width: 100%;
                max-width: 25%;
                padding: 12px 0;
            }
        }
    }
</style>
